package com.qf.controller;

import com.qf.j2105.po.Task;
import com.qf.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 管理员主要的功能
 * 1.查看所有任务详情
 * 2.分配任务给相应的员工
 *
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private TaskService taskService;
    //查看所有
    @RequestMapping(value = "/selectall",method = RequestMethod.GET)
    public List<Task> selectall(){
        List<Task> selectquery = taskService.selectquery();
        return selectquery;
    }
    //根据id查一条数据
    @RequestMapping(value = "/selectone/{id}",method = RequestMethod.GET)
    public Task selectone(@PathVariable("id") int id){
        Task task = taskService.queryById(id);
        return task;
    }
    @RequestMapping(value = "/updataone",method = RequestMethod.PUT)
    public Task updataoneTask(Task task ){
        Task update = taskService.update(task);
        return update;
    }
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Task insertone(Task task){
        Task insert = taskService.insert(task);
        return insert;
    }
}
